package it.koutifaris.travianmap.ui.drawhelpers.village;

import it.koutifaris.travianmap.model.Tribe;
import it.koutifaris.travianmap.model.Village;
import it.koutifaris.travianmap.ui.PointToSquareHelper;

import java.util.EnumMap;

import android.graphics.Paint;
import android.graphics.Paint.Style;

public class LowDetailsVillageDrawer extends AbstractVillageDrawer implements VillageDrawer {

	private EnumMap<Tribe, Paint> paints;

	public LowDetailsVillageDrawer(PointToSquareHelper pointToSquareHelper) {
		super(pointToSquareHelper);
	}

	@Override
	public void drawVillage(Village village, int x, int y) {
		int right = getXInViewPort(x) + getViewState().getSquareSize();
		int bottom = getYInViewPort(y) + getViewState().getSquareSize();

		getCanvas().drawRect(getXInViewPort(x), getYInViewPort(y), right, bottom, getPaint(village));
	}

	private Paint getPaint(Village village) {
		if (paints == null) {
			initPaintsMap();
		}

		return paints.get(village.getOwner().getTribe());
	}

	private void initPaintsMap() {
		paints = new EnumMap<Tribe, Paint>(Tribe.class);

		Paint paint = new Paint();
		paint.setStyle(Style.FILL);
		paint.setARGB(255, 100, 100, 255);
		paints.put(Tribe.GAUL, paint);

		paint = new Paint();
		paint.setStyle(Style.FILL);
		paint.setARGB(255, 255, 100, 100);
		paints.put(Tribe.ROMAN, paint);

		paint = new Paint();
		paint.setStyle(Style.FILL);
		paint.setARGB(255, 255, 255, 100);
		paints.put(Tribe.TEUTON, paint);

		paint = new Paint();
		paint.setStyle(Style.FILL);
		paint.setARGB(255, 255, 255, 255);
		paints.put(Tribe.NATARS, paint);

		paint = new Paint();
		paint.setStyle(Style.FILL);
		paint.setARGB(255, 255, 255, 255);
		paints.put(Tribe.NATURE, paint);
	}

}
